<?php /* УТФ-8:fix */

class SPIcontroller__json extends SPIcontroller__dummy
{
    private $json_object;

    public function __construct()
    {
        if( function_exists('json_encode') === false || function_exists('json_decode') === false )
        {
            require_once( SPIcfg::$util['json']['base_script'] );
            
            $this->json_object = new Services_JSON();
        }

        return true;
    }
    
    public function encode( & $content )
    {
        if( function_exists('json_encode') === true )
        {
            return json_encode( $content );
        }
        
        return $this->json_object->encode( $content );
    }
    
    public function decode( & $content )
    {
        if( function_exists('json_decode') === true )
        {
            return json_decode( $content );
        }
        
        return $this->json_object->decode( $content );
    }
}
